/*
* 获取 窗口 (XY) 宽高
*/
export function clientXY () {
  if (window.innerHeight !== undefined) {
    return {
      width: window.innerWidth,
      height: window.innerHeight
    }
  } else if (document.compatMode === 'CSS1Compat') {
    return {
      width: document.documentElement.clientWidth,
      height: document.documentElement.clientHeight
    }
  } else {
    return {
      width: document.body.clientWidth,
      height: document.body.clientHeight
    }
  }
}

/*
* 判断 Object 是否为空
*/
export function isEmptyObject (obj) {
  const tmpArr = Object.keys(obj)
  return tmpArr.length > 0
}

/*
* 生成AddDayCount天之前/之后的年月日
*/
export function GetDateAfterNum (AddDayCount = 0) {
  const dd = new Date()
  dd.setDate(dd.getDate() + AddDayCount)// 获取AddDayCount天后的日期
  const y = dd.getFullYear()
  let m = dd.getMonth() + 1// 获取当前月份的日期
  let d = dd.getDate()
  if (m >= 1 && m <= 9) {
    m = '0' + m
  }
  if (d >= 0 && d <= 9) {
    d = '0' + d
  }
  return y + '-' + m + '-' + d
}

// 验证手机号码是否正确
export function isMobile (s) {
  const patrn = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
  if (!patrn.exec(s)) { return false }
  return true
}
